#ifndef APP_MAIN_VIEW_H
#define APP_MAIN_VIEW_H

#include "app_main_model.h"
#include "hal_rtc_device.h"

class AppMainView {
 public:
  void UpdateSensorState(const AppSensorModel& state);
  void UpdateLocationState(const AppLocationModel& location);
  void UpdateRealtimeWeather(const AppRealtimeWeather& weather);
  void UpdateForecastWeather(const AppForecastWeather& weather);

  /// @brief 初始化，加载字体等
  bool Initialize();

  void SetRtcDevice(HalRtcDevice* device);

  /// @brief 绘制主界面
  void DrawMainView();

  /// @brief 绘制配置加载界面
  void DrawConfigLoadView();

  /// @brief 绘制WiFi联网界面
  void DrawWifiConnectView();

  /// @brief 绘制时间请求界面
  void DrawTimeRequestView();

  /// @brief 绘制时间更新界面
  void DrawTimeUpdateView();

  /// @brief 绘制位置请求界面
  void DrawLocationRequestView();

  /// @brief 绘制天气请求界面
  void DrawWeatherRequestView();

 private:
  void DrawGridLayout();
  void DrawSensorState();
  void DrawLocationState();
  void DrawDateTime();
  void DrawRealtimeWeather();
  void DrawForecastWeather();
  void DrawFooterText();

  void SetCursor(int x, int y);
  void DrawString(String str);

 private:
  int32_t xCursor_{0};
  int32_t yCursor_{0};
  int32_t yBaseLine_{0};
  bool sensorUpdated_{false};
  bool locationUpdated_{false};
  bool rtWeatherUpdated_{false};
  bool fcWeatherUpdated_{false};
  AppSensorModel sensorState_;
  AppLocationModel locationState_;
  AppRealtimeWeather realtimeWeather_;
  AppForecastWeather forecastWeather_;
  HalRtcDevice* rtcDevice_{nullptr};
};

#endif  // APP_MAIN_VIEW_H